import cookies from "react-cookies";

const token = "access_token";
const refresh_token = "refresh_token";
const user = "username";
const department = "department";
const avatar = "avatar";

// 存获access_token
export function setToken(value){
    cookies.save(token, value, { path: '/' });
}
export function getToken(){
    return cookies.load(token);
}

// 存获refresh_token
export function setRefreshToken(value){
    cookies.save(refresh_token, value, { path: '/' });
}
export function getRefreshToken(){
    return cookies.load(refresh_token);
}

// 存获用户名
export function setUsername(value){
    cookies.save(user, value, { path: '/' });
}
export function getUsername(){
    return cookies.load(user);
}

export function getUserAvatar(){
    return cookies.load(avatar);
}

// 存获事业部名称
export function setDepartment(value){
    cookies.save(department, value, { path: '/' });
}
export function getDepartment(){
    return cookies.load(department);
}

// logout清除信息
export function removeToken(){
    cookies.remove(token, { path: '/' });
}
export function removeUsername(){
    cookies.remove(user, { path: '/' });
}
export function removeRefreshToken(){
    cookies.remove(refresh_token, { path: '/' });
}
export function removeDepartment(){
    cookies.remove(department, { path: '/' });
}